# 版本限定 
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)     


# 设置编译器选项：O3优化，显示所有警告
SET(CMAKE_C_FLAGS "$ENV{CFLAGS} -O3 -Wall -g -lstdc++  -mcpu=cortex-a53 -mfloat-abi=softfp -mfpu=neon")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2  -std=c++0x -Wall -g -lstdc++ ")

set(CROSS_TOOLCHAIN_PREFIX "/opt/hisi-linux/x86-arm/aarch64-himix100-linux/bin/")
set(CMAKE_CXX_COMPILER ${CROSS_TOOLCHAIN_PREFIX}aarch64-himix100-linux-g++)
set(CMAKE_C_COMPILER ${CROSS_TOOLCHAIN_PREFIX}aarch64-himix100-linux-gcc)

# 项目名称 
PROJECT(opencv_video.out)

# 定义头文件的路径变量
SET(INCLUDE_PATH ${PROJECT_SOURCE_DIR}/include) 

#MESSAGE(STATUS "Include Path, ${INCLUDE_PATH}")

#头文件
#include_directories(${PROJECT_SOURCE_DIR})
include_directories(${PROJECT_SOURCE_DIR}/common)
# include_directories(/home/xiangang/xg/haisi/ffmpeg-3.3.9/install/include)

# 定义库文件路径
SET(LIB_PATH ${PROJECT_SOURCE_DIR}/lib)
MESSAGE(STATUS "Libs Path: ${LIB_PATH}")

# 定义源文件路径变量
SET(SOURCE_PATH ${PROJECT_SOURCE_DIR}/src) 
MESSAGE(STATUS "Source Path : ${SOURCE_PATH}") 

# 包含头文件搜索路径
INCLUDE_DIRECTORIES(${INCLUDE_PATH}) 

# 包含库搜索路径
LINK_DIRECTORIES(${LIB_PATH} ${PROJECT_SOURCE_DIR}/lib)
LINK_DIRECTORIES(${LIB_PATH} ${PROJECT_SOURCE_DIR}/lib/ffmpeg)
# LINK_DIRECTORIES(${LIB_PATH} /home/xiangang/xg/haisi/ffmpeg-3.3.9/install/lib/)


#3.head file path，头文件目录
INCLUDE_DIRECTORIES(
${PROJECT_SOURCE_DIR}/include
/usr/local/include
/usr/local/include/opencv
/usr/local/include/opencv2
)

set(OpenCV_DIR /home/xiangang/xg/haisi/arm-opencv-3.3.0-build)
find_package(OpenCV REQUIRED)

message(STATUS "    OpenCV library status:")
message(STATUS "    version: ${OpenCV_VERSION}")
message(STATUS "    libraries: ${OpenCV_LIBS}")
message(STATUS "    include path: ${OpenCV_INCLUDE_DIRS}")

# 定义待链接库名字
# 链接静态库
# SET(LIBS_LIST 
# libavformat.a
# libavcodec.a
# libavutil.a
# libswresample.a
# libmpi.a
# libsecurec.a
# lib_hiae.a
# libisp.a
# lib_hidehaze.a
# lib_hidrc.a
# lib_hildci.a
# libsns_imx477.a
# libsns_imx290.a
# libsns_imx334.a
# libsns_imx334_slave.a
# libsns_imx277_slvs.a
# lib_hiawb.a
# libhdmi.a
# libdpu_rect.a
# libdpu_match.a
# libhiavslut.a
# libpos_query.a
# libmotionfusion.a
# libVoiceEngine.a
# libupvqe.a
# libdnvqe.a
# )   
                                                                                  
# 链接动态库
#SET(LIBS_LIST libavcodec.so libavdevice.so libavfilter.so libavformat.so libavutil.so libpostproc.so libswresample.so libswscale.so)
#SET(LIBS_LIST libqsImgLib.so libipu.so libvpu.so libavcodec.so libavformat.so)
# 添加源文件路径下所有源文件存放到变量中(*.c && *.cpp)
AUX_SOURCE_DIRECTORY(${SOURCE_PATH} SRC_LIST)
SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)

#set(OpenCV_DIR /home/xiangang/xiangang/opencv/arm-opencv-3.3.0)  
#set(OpenCV_LIBS /home/xiangang/xiangang/opencv/arm-opencv-3.3.0/lib)  
#include_directories(/home/xiangang/xiangang/opencv/arm-opencv-3.3.0/include) 

#find_package( OpenCV REQUIRED )

# 设置生成可执行文件的名称
SET(EXECUTABLE_FILE_NAME opencv_video.out)

# 生成可执行文件
ADD_EXECUTABLE(${EXECUTABLE_FILE_NAME} ${SRC_LIST})

# 设置可执行文件链接的库名称
TARGET_LINK_LIBRARIES(${EXECUTABLE_FILE_NAME}  ${OpenCV_LIBS} -lm -lpthread -lrt -ldl)
